﻿@using HelpDeskTicketingApp.Models
@model  HomeIndexViewModel
@{
    ViewBag.Title = "ViewTickets";
    int closedCount = 0;
    int openCount = 0;
    string workedOn = null;
}

<h2>All Tickets</h2>
<a class="btn btn-info" href="/Home/AddTicket"> Create New Ticket</a><br /><br />
<div class="row">

    <div class="col-md-6">

      
            <div class="box box-info">
                <div class="box-header">
                    <i class="fa fa-bullhorn"></i>
                    <h3 class="box-title">Closed Tickets</h3>
                </div><!-- /.box-header -->
                <div class="box-body">
                   
                    @foreach (var i in Model.issues)
                    {

                        if (i.Resolution.IsResolved == true)
                        {
                            <p>
                               
                                @i.IssueDesc
                                <br />
                                @i.DateResolved<br />
                                @foreach (var it in Model.Types)
                                {
                                    if (i.IssueType.IssueTypeId == it.Value)
                                    {
                                        i.IssueType.IssueTypeDesc = it.Display;
                                    }
                                }

                                Issue Type: @i.IssueType.IssueTypeDesc<br />
                               
                                
                                @Html.ActionLink("Full View", "ViewNotes", new { Id = i.IssueId })<br />
                            </p>
                            closedCount++;
                        }
                    }

                    @if (closedCount < 1)
                    {
                        <h3>No Tickets!</h3>
                    }
               <!-- /.box-body -->
            </div><!-- /.box -->
        </div>

      

    </div>





    <div class="col-md-6">

        <div class="box box-danger">
            <div class="box-header">
                <i class="fa fa-bullhorn"></i>
                <h3 class="box-title">Open Tickets</h3>
            </div><!-- /.box-header -->
            <div class="box-body">

    @foreach (var i in Model.issues)
    {

        if (i.Resolution.IsResolved == false)
        {
           
                <div class="callout callout-danger">
                    <h4>@i.IssueType.IssueTypeDesc</h4>
                    <p> </p>
                   
                    @i.IssueDesc
                    <br />
                    @i.DateReported<br />
                    @foreach (var it in Model.Types)
                    {
                        if (i.IssueType.IssueTypeId == it.Value)
                        {
                            i.IssueType.IssueTypeDesc = it.Display;
                        }
                    }
                    Issue Type: @i.IssueType.IssueTypeDesc<br />
                    
                    Is it being worked on: <label class="label label-info">@if (i.IsAssigned == true) { workedOn = "Yes"; } else { workedOn = "No"; }@workedOn<br /></label><br />
                    @Html.ActionLink("Edit", "EditTicket", new { Id = i.IssueId })<br />
            

        </div>
            openCount++;

        }
    }
                @if (openCount < 1)
                {
                    <h3>No Open Tickets!</h3>
                }
            </div><!-- /.box-body -->
            </div><!-- /.box -->
    

    </div>
</div>



